<?php

namespace app\admin\model\template;

use think\Model;

class OrderCommissionRecord extends Model
{

    // 定义关联的数据表名称
    protected $name = 'order_commission_record';
    // 开启自动时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    public function getCreatetimeAttr($value)
    {
        if (empty($value)) return null;
        $currentYear = date('Y');
        $date = date('Y', $value);
        return $currentYear == $date ? date('m-d H:i:s', $value) : date('Y-m-d H:i:s', $value);
    }

    public function getFeeAttr($value)
    {
        return $value;
    }

    public function orderInfo()
    {
        return $this->belongsTo(Order::class, 'order_id', 'id');
    }

}